package com.ecp.commons.db;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.json.JSONObject;

import com.ecp.commons.bean.Page;

public interface Generic<T> {

	int generateId(T obj) throws Exception;

	void add(T t) throws Exception;

	void addBatch(List<T> list, boolean inTrans) throws Exception;

	void update(T t) throws Exception;

	void delete(Serializable pk, T t) throws Exception;

	void deleteBatch(List<?> pks, T t, boolean inTrans) throws Exception;
	
	T load(Serializable pk, T t) throws Exception;

	T getEntity(String sql, Object[] args, T t) throws Exception;

	T getEntity(String[] keys, Object[] args, T t) throws Exception;

	List<T> getAll(T t) throws Exception;

	List<T> getEntityList(String sql, Object[] args, T t) throws Exception;

	List<T> getEntityList(String sql, Object[] args, T t, Page page) throws Exception;

	List<T> getEntityList(String[] keys, Object[] args, Page page, T t) throws Exception;

	List<Integer> getEntityIdList(String sql, Object[] args) throws Exception;

	List<Integer> getEntityIdList(String sql, Object[] args, Page page) throws Exception;

	int execute(String sql, Object[] args, T t);

	List<T> getEntityList(Map<String, JSONObject> map, T t, Page page, String orderBy) throws Exception;

	List<JSONObject> search(String sql, Object[] args, Page page) throws Exception;
}
